<?php
# Tratamiento invasivo
echo "<table cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">\n";

echo "<tr><td colspan=\"3\">\n";
echo "<div class=\"subtitle\">Tratamiento invasivo</div>\n";
echo "</td></tr>\n";

echo "<tr valign=\"top\">\n";
echo "<td colspan=3>\n";
echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n";
echo "<tr valign=\"top\">\n";

echo "<td width=\"60%\">\n";
echo "<div class=\"optionlistLayer2\">\n";
echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n";

$query = "SELECT id_trataminvas, trataminvas FROM listatrataminvas ORDER BY trataminvas";
$q_trataminvas = mysql_query($query, $sock);

echo "<input type=\"hidden\" name=\"num_trataminvas\" value=\"".mysql_num_rows($q_trataminvas)."\">\n";
$contador = 0;

while ($row_trataminvas = mysql_fetch_object($q_trataminvas))
{
	$id_trataminvas = $row_trataminvas->id_trataminvas;
	$trataminvas = $row_trataminvas->trataminvas;

	if (isset($arr_trataminvas) && in_array($id_trataminvas, $arr_trataminvas)) $sel_trataminvas .= $contador.",";

	echo "<input type=\"hidden\" name=\"id_trataminvas[".$contador."]\" value=\"".$id_trataminvas."\">\n";
	echo "<input type=\"hidden\" name=\"txt_trataminvas[".$contador."]\" value=\"".htmlentities(stripslashes($trataminvas), ENT_QUOTES)."\">\n";

	echo "<tr valign=\"top\">\n";
	echo "<td width=\"1%\"><input type=\"checkbox\" name=\"trataminvas[".$contador."]\" class=\"checkBox\"".(isset($arr_trataminvas) && in_array($id_trataminvas, $arr_trataminvas) ? " checked" : "")." onclick=\"selectCheck('sel_trataminvas', ".$contador.", this.checked); updateLayerinfo('trataminvas');\"></td>\n";
	echo "<td width=\"98%\">".stripslashes($trataminvas)."</td>\n";
	echo "<td width=\"1%\" align=\"right\"><input type=\"text\" name=\"dosistrataminvas[".$contador."]\" class=\"textBox2\" value=\"".(isset($arr_trataminvas) && in_array($id_trataminvas, $arr_trataminvas) ? htmlentities(stripslashes($arr_dosistrataminvas[$id_trataminvas]), ENT_QUOTES) : "[dosis]")."\" onfocus=\"if (this.value == '[dosis]') this.value = '';\" onblur=\"if (this.value == '') {this.value = '[dosis]'};\"></td>\n";
	echo "<td width=\"1%\" style=\"padding-left: 4px\"><input type=\"checkbox\" name=\"rxtrataminvas[".$contador."]\" class=\"checkBox\"".(isset($arr_trataminvas) && in_array($id_trataminvas, $arr_trataminvas) && $arr_rxtrataminvas[$id_trataminvas] == 1 ? " checked" : "")."></td>\n";
	echo "<td width=\"1%\" style=\"padding-right: 4px\">Rx</td>\n";
	echo "</tr>\n";

	$contador ++;
}

echo "<input type=\"hidden\" name=\"sel_trataminvas\" value=\"".(isset($sel_trataminvas) ? $sel_trataminvas : "")."\">\n";

echo "</table>\n";
echo "</div>\n";

echo "<div style=\"margin-top: 3px; margin-right: 8px; text-align: right\">\n";
echo "Fecha prevista: <select name=\"diatrataminvas\" class=\"day_comboBox\"><option value=\"\"></option>";
for ($x=1; $x<=31; $x++) echo "<option value=\"".$x."\"".(intval($fecha_trataminvas[2]) == $x ? " selected" : "").">".$x."</option>";
echo "</select> <select name=\"mestrataminvas\" class=\"month_comboBox\">";
foreach ($GLOBALS["meses"] as $nummes => $mes) echo "<option value=\"".$nummes."\"".(intval($fecha_trataminvas[1]) == $nummes ? " selected" : "").">".ucfirst($mes)."</option>";
echo "</select> <select name=\"anotrataminvas\" class=\"year_comboBox\"><option value=\"\"></option>";
for ($x=date("Y")+2; $x>=date("Y"); $x--) echo "<option value=\"".$x."\"".($fecha_trataminvas[0] == $x ? " selected" : "").">".$x."</option>";
echo "</select>\n";
echo "</div>\n";

echo "</td>\n";

echo "<td width=\"25%\"><div id=\"info_trataminvas\" class=\"infoLayer3\"></div></td>\n";
echo "<td width=\"15%\"><textarea name=\"amp_trataminvas\" class=\"ampBox3\">".(isset($row_consultas) ? stripslashes($row_consultas->amp_trataminvas) : "")."</textarea></td>\n";

echo "</tr>\n";
echo "</table>\n";
echo "</td>\n";
echo "</tr>\n";

echo "</table>\n";
?>